package com.sky.lightleafpicturepavilionserver.controller;

import com.sky.lightleafpicturepavilionserver.common.Result;
import com.sky.lightleafpicturepavilionserver.dto.HomeBannerDTO;
import com.sky.lightleafpicturepavilionserver.service.HomeBannerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页Banner轮播图控制器
 */
@Tag(name = "首页Banner轮播图", description = "首页Banner轮播图相关接口")
@Validated
@RestController
@RequestMapping("/api/v1/homeBanner")
@Slf4j
@RequiredArgsConstructor
public class HomeBannerController {

    private final HomeBannerService homeBannerService;

    /**
     * 获取首页Banner列表
     * @return Banner列表（固定5个）
     */
    @Operation(summary = "获取首页Banner列表", description = "获取首页轮播图列表，固定返回5个Banner，点击跳转到壁纸分类大全页面")
    @GetMapping("/list")
    public Result<List<HomeBannerDTO>> getBannerList() {
        log.info("请求获取首页Banner列表");
        
        try {
            List<HomeBannerDTO> bannerList = homeBannerService.getHomeBannerList();
            return Result.success("获取Banner列表成功", bannerList);
        } catch (Exception e) {
            log.error("获取Banner列表失败", e);
            return Result.error("获取Banner列表失败");
        }
    }
}
